package com.zhiyou.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyou.entity.House;
import com.zhiyou.entity.Lessee;
import com.zhiyou.entity.Rent;
import com.zhiyou.service.RentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;

@RestController
@RequestMapping(value = "/rent")
public class RentController {
    @Autowired
    RentService rentService;
     @RequestMapping("/getAll")
    public PageInfo<Rent> getAll(Integer pageNo,Integer pageSize){
         PageInfo<Rent> page = rentService.getAll(pageNo,pageSize);
        return page;
    }

    @RequestMapping("/selectOneByRId")
    public Rent selectOneByRId(Integer rId){
        Rent rent = rentService.selectOneByRId(rId);
         return rent;
    }
    @RequestMapping("/update")
    public int update(Rent rent){

        int i= rentService.update(rent);
        return i ;
    }
    @RequestMapping("/delete")
    public boolean update(Integer rId){

        boolean flag= rentService.delete(rId);
        return flag ;
    }

    @RequestMapping("/getHouse")
    public List<House> getHouse(){
        List<House> lists =rentService.getHouse();
         return lists;
    }
    @RequestMapping("/getLessee")
    public List<Lessee> getLessee(){
        List<Lessee> lists =rentService.getLessee();
         return lists;
    }
//    添加模块
    @RequestMapping(value = "insert")
    public int insert(Rent rent){
        System.out.println("rent = " + rent);
         int i=rentService.insertRent(rent);
         return i;
    }
//    模糊查询
    @RequestMapping(value = "/getRentLikeAll")
    public PageInfo<Rent> getRentLikeAll(String like,Integer pageNo,Integer pageSize){
        PageInfo<Rent> pageInfo= rentService.getRentLikeAll(like,pageNo,pageSize);
        System.out.println("pageInfo = " + pageInfo);
         return pageInfo;
    }


}

